package org.example.lds240404.system;

import java.util.Random;

/**
 * @author: hero生仔
 */
public class Main {
    public static void main(String[] args) {
        Student student1 = new Student("111", "lds", 23, true);
        Student student2 = new Student("122", "lww", 23, false);
        Student student3 = new Student("133", "chx", 23, true);
        Student student4 = new Student("144", "zjt", 23, true);

        StudentSystem studentSystem = new StudentSystem();
        studentSystem.addStudent(student1);
        studentSystem.addStudent(student2);
        studentSystem.addStudent(student3);
        studentSystem.addStudent(student4);


        String[] arr = new String[]{"111", "122", "133", "144"};
        Random random = new Random();

        for (int i = 0; i < 10; i++) {
            int idx = random.nextInt(4);
            System.out.println("索引为：" + idx);
            String id = arr[idx];

            new Thread(() -> {
                try {
                    Student student = studentSystem.getStudent(id);
                    System.out.println(student);
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }).start();
        }

    }
}
